SOURCE_DIR = ./{{cookiecutter.project_slug}}

.PHONY: clean help

help:
	clear;
	@echo "================= Usage =================";
	@echo "clean                  : Remove autogenerated folders";
	@echo "clean-pyc              : Remove python artifacts."
	@echo "clean-build            : Remove build artifacts."
	@echo "bandit                 : Install and run bandit security analysis.";
	@echo "mypy                   : Install and run mypy type checking.";
	@echo "flake8                 : Install and run flake8 linting.";
	@echo "test                   : Run tests and generate coverage report.";
	@echo "build_whl              : Build a python wheel package.";

# Clean the folder from build/test related folders
clean: clean-build clean-pyc
	rm -rf .mypy_cache/ .pytest_cache/
	rm -f .coverage

clean-pyc:
	find . \( -name '*.pyc' -o -name '*.pyo' \) -exec rm -rf {} +

clean-build:
	rm -rf build/ dist/ *.egg-info

# Install and run bandit security analysis
bandit:
	python3 -m pip install bandit
	python3 -m bandit -r $(SOURCE_DIR)

# Install and run mypy type checking
mypy:
	python3 -m pip install -r requirements/dev.txt
	python3 -m mypy $(SOURCE_DIR)

# Install and run flake8 linting
flake8:
	python3 -m  pip install flake8
	python3 -m flake8 $(SOURCE_DIR)

# Install requirements for testing and run tests
test:
	python3 -m  pip install -r requirements/dev.txt
	python3 -m  pip install -e .
	python3 -m pytest

# build wheel package
build_whl:
	python3 setup.py bdist_wheel